package cn.itcast.hotel.controller;

import cn.itcast.hotel.dto.RequestParamsDto;
import cn.itcast.hotel.service.IHotelService;
import cn.itcast.hotel.vo.PageResultVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;
import java.util.List;
import java.util.Map;


/**
 *  前端控制器
 */
@Transactional
@RestController
@RequestMapping("hotel")
public class HotelController {

    @Autowired
    private IHotelService hotelService;

    @PostMapping("/list")
    public PageResultVo list(@RequestBody RequestParamsDto params) throws IOException {
        return hotelService.search(params);
    }

    @PostMapping("/filters")
    public Map<String, List<String>> filters(@RequestBody RequestParamsDto params) {
        return hotelService.filter(params);
    }
}
